package cn.ffcs.uec.outStaff.component;

import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import lombok.Getter;
import lombok.Setter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.SuspendNotAllowedException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zul.Div;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;

import cn.ffcs.raptornuke.plugin.common.zk.util.ZkUtil;
import cn.ffcs.raptornuke.portal.PortalException;
import cn.ffcs.raptornuke.portal.SystemException;
import cn.ffcs.uec.common.manager.CustomFilesManager;
import cn.ffcs.uec.common.util.PermissionUtil;
import cn.ffcs.uec.organization.manager.UecOrgDeptManager;
import cn.ffcs.uec.organization.manager.UecOrgOrgsManager;
import cn.ffcs.uec.organization.model.UecOrgDept;
import cn.ffcs.uec.organization.model.UecOrgOrgs;
import cn.ffcs.uec.outStaff.component.bean.UecOutStaffInfoListboxBean;
import cn.ffcs.uec.outStaff.constant.UecOutStaffConstants;
import cn.ffcs.uec.outStaff.manager.UecOutStaffManager;
import cn.ffcs.uec.outStaff.model.UecOutStaffInfo;
import cn.ffcs.uec.outStaff.vo.UecOutStaffInfoVo;
import cn.ffcs.uec.outStaffEntryApply.component.OutStaffEntryApplyListboxExt;
import cn.ffcs.uec.staff.manager.UecNationdutyManager;
import cn.ffcs.uec.staff.manager.UecPartyLogManager;
import cn.ffcs.uec.staff.manager.UecPsnjobManager;
import cn.ffcs.uec.staff.manager.UecTitleManager;
import cn.ffcs.uec.staff.model.UecNationduty;
import cn.ffcs.uec.staff.model.UecPartyLog;
import cn.ffcs.uec.staff.model.UecPsnjob;
import cn.ffcs.uec.staff.model.UecTitle;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.DateUtil;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.PlatformUtil;
import cn.ffcs.uom.common.util.PubUtil;
import cn.ffcs.uom.common.util.StrUtil;

@Controller
@Scope("prototype")
public class UecOutStaffInfoListboxExt extends Div implements IdSpace {
	protected final Log log = LogFactory.getLog(this.getClass());
	private static final long serialVersionUID = -2212731640371254189L;

	/**
	 * 对应页面上的bean
	 */
	@Getter
	@Setter
	private UecOutStaffInfoListboxBean bean = new UecOutStaffInfoListboxBean();

	/**
	 * 人员基本信息对象
	 */
	private UecOutStaffInfo uecOutStaffInfo = new UecOutStaffInfo();
	/**
	 * 外包人员虚拟对象
	 */
	private UecOutStaffInfoVo uecOutStaffInfoVo;
	/**
	 * 关闭窗口标志
	 */
	private Boolean onCloseFlag = true;

	/**
	 * 人员基本信息查询对象
	 */
	private UecOutStaffInfo qryUecOutStaffInfo;
	/**
	 * 职业资格管理实体
	 */
	//private UecNationduty uecNationduty = new UecNationduty();
	/**
	 * 专业技术职务实体
	 */
	private UecTitle uecTitle = new UecTitle();

	private UecTitleManager uecTitleManager = (UecTitleManager) ApplicationContextUtil.getBean("uecTitleManager");

	private UecNationdutyManager uecNationdutyManager = (UecNationdutyManager) ApplicationContextUtil
			.getBean("uecNationdutyManager");

	private UecOutStaffManager uecOutStaffManager = (UecOutStaffManager) ApplicationContextUtil
			.getBean("uecOutStaffManager");

	private UecOrgOrgsManager uecOrgOrgsManager = (UecOrgOrgsManager) ApplicationContextUtil
			.getBean("uecOrgOrgsManager");
	private UecOrgDeptManager uecOrgDeptManager = (UecOrgDeptManager) ApplicationContextUtil
			.getBean("uecOrgDeptManager");
	private CustomFilesManager customFilesManager = (CustomFilesManager) ApplicationContextUtil
			.getBean("customFilesManager");

	private UecPsnjobManager uecPsnjobManager = (UecPsnjobManager) ApplicationContextUtil.getBean("uecPsnjobManager");
	
	/**
	 * 政治面貌
	 */
	private UecPartyLogManager uecPartyLogManager = (UecPartyLogManager) ApplicationContextUtil.getBean("uecPartyLogManager");
	/**
	 * 教育经历
	 */
	//private UecDocEduManager uecDocEduManager = (UecDocEduManager) ApplicationContextUtil.getBean("uecDocEduManager");
	

	@Getter
	@Setter
	private IPortletInfoProvider portletInfoProvider;

	public UecOutStaffInfoListboxExt() {
		Executions.createComponents(UecOutStaffConstants.UEC_STAFF_INFO_EXT_LISTBOX_ZUL, this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');

		this.addForward("onSelectUecOutStaffInfoByGetOrgTree", this, "onSelectUecOutStaffInfoByGetOrgTreeResponse");

	}
	
	/**
	 * 初始化
	 * 
	 * @throws ParseException
	 */
	public void onCreate() throws ParseException {
		bandBean();
	}

	/**
	 * 监听事件
	 * 
	 * @param event
	 * @throws Exception
	 */
	public void onSelectUecOutStaffInfoByGetOrgTreeResponse(ForwardEvent event) throws Exception {
		uecOutStaffInfo = (UecOutStaffInfo) event.getOrigin().getData();
		if (null != uecOutStaffInfo) {
			this.bean.getHbox1().setVisible(false);
			qryUecOutStaffInfo = UecOutStaffInfo.newInstance();
			qryUecOutStaffInfo = uecOutStaffInfo;
			queryOutStaffInfoAndGetView();
		}
	}

	/**
	 * 绑定
	 * 
	 * @throws ParseException
	 */
	public void bandBean() throws ParseException {
		String code = PlatformUtil.getCurrentUser().getScreenName().substring(1).toUpperCase();
		String managerOrg = PermissionUtil.getManagerOrg();
		if (managerOrg == null) {
			bean.getConditionCaption().setVisible(false);
			qryUecOutStaffInfo = UecOutStaffInfo.newInstance();
			qryUecOutStaffInfo.setPsnCode(code);
			qryUecOutStaffInfo = uecOutStaffManager.findUecOutStaffInfo(qryUecOutStaffInfo);
			PubUtil.fillBeanFromPo(qryUecOutStaffInfo, bean);
			bean.getPkOrg().setValue(qryUecOutStaffInfo.getPkHrOrgName());
			uecOutStaffInfo = qryUecOutStaffInfo;
			// 判断PkHrorg是否为空
			if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getPkHrorg())) {
				bean.getPkHrorgName()
						.setValue(uecOrgOrgsManager.getUecOrgOrgsNameByPkOrg(qryUecOutStaffInfo.getPkHrorg()));
			}
			groupDataTranslationDisplay();
		}
	}


	/**
	 * 查询按钮
	 * 
	 * @throws Exception
	 */
	public void onQuery() throws Exception {

		clearVariable();
		PubUtil.clearComponent(this.bean.getBasePanel());
		qryUecOutStaffInfo = UecOutStaffInfo.newInstance();
		uecOutStaffInfoVo = new UecOutStaffInfoVo();
		/**
		 * 组织树Ext UecOrganizationTreeBandboxExt 组织树上有组织和部门 通过组织树获取组织或部门
		 */
		if (!StrUtil.isNullOrEmpty(bean.getOutStaffPkHrorg().getValue())) {
			// 组织类型：公司 or 部门
			String orgType = (String) bean.getOutStaffPkHrorg().getOrganization().getOrgType();
			// 组织主键
			String pkorg = (String) bean.getOutStaffPkHrorg().getOrganization().getOrg();
			if ("ORG".equals(orgType)) {
				String orgName = (String) bean.getOutStaffPkHrorg().getOrganization().getOrgName();
				// 公司
				//uecOutStaffInfoVo.setPkOrg(pkorg);
		       	 if("中国电信股份有限公司内蒙古分公司".equals(orgName)) {
		       		uecOutStaffInfoVo
		       		.setOrgName(null);
		       	}else if(orgName.endsWith("*")){
		       		uecOutStaffInfoVo
		       		.setOrgName(orgName);
		       	}else {
		       		uecOutStaffInfoVo.setPkOrg(pkorg);
		       	}
			} else {
				// 部门
				UecOrgDept uecOrgDept = new UecOrgDept();
				UecOrgOrgs uecOrgOrgs = new UecOrgOrgs();
				uecOrgDept.setPkDept(pkorg);
				uecOrgDept = uecOrgDeptManager.findUecOrgDeptByOrgDept(uecOrgDept);
				// 部门所属公司
				if(uecOrgDept !=null) {
					uecOrgOrgs= new UecOrgOrgs();
					uecOrgOrgs.setPkOrg(uecOrgDept.getPkOrg());
					uecOrgOrgs = uecOrgOrgsManager.findUecOrgOrgsByUecOrgOrgs(uecOrgOrgs);
					String orgName=uecOrgOrgs.getName();
					uecOutStaffInfoVo.setPkDept(uecOrgDept.getPkDept());
					uecOutStaffInfoVo.setPkOrg(uecOrgDept.getPkOrg());
					uecOutStaffInfoVo.setOrgName(orgName);
			//	uecOutStaffInfoVo.setPkDept(pkorg);
			}
		}
	}
		uecOutStaffInfoVo.setStaffCode(bean.getOutStaffCode().getValue());
		uecOutStaffInfoVo.setStaffName(bean.getOutStaffName().getValue());
		uecOutStaffInfoVo.setIdNum(bean.getOutStaffIdNum().getValue());
		outStaffList();
}
	/**
	 * 员工列表
	 * 
	 * @throws Exception
	 * @throws SuspendNotAllowedException
	 */
	public void outStaffList() throws SuspendNotAllowedException, Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("opType", "outStaffList");
		map.put("uecOutStaffInfoVo", uecOutStaffInfoVo);

		Window window = (Window) Executions.createComponents(UecOutStaffConstants.UEC_OUT_STAFF_LIST_ZUL, this, map);
		window.doModal();
		window.addEventListener("onOK", new EventListener() {
			@Override
			public void onEvent(Event event) throws Exception {
				if (event.getData() != null) {
					qryUecOutStaffInfo = (UecOutStaffInfo) event.getData();
					queryOutStaffInfoAndGetView();
				}
			}
		});
	}

	/**
	 * 
	 * @throws ParseException
	 */
	public void queryOutStaffInfoAndGetView() throws ParseException {
		// 查询时重新计算工龄
		Integer workYears = OutStaffEntryApplyListboxExt.getWorkingYears(qryUecOutStaffInfo.getJoinWorkDate());
		qryUecOutStaffInfo.setDef3(workYears.toString());
		// 本企业工龄：当前日期 – 进入本单位日期
		Integer theWorkYears = OutStaffEntryApplyListboxExt.getWorkingYears(qryUecOutStaffInfo.getEnterUnitTime());
		qryUecOutStaffInfo.setDef4(theWorkYears.toString());
		qryUecOutStaffInfo.updateOnly();
		// 查询时重新计算本企业工龄
		PubUtil.fillBeanFromPo(qryUecOutStaffInfo, bean);
		// 重新绑定下日期
		stringTransToDate();
		uecOutStaffInfo = qryUecOutStaffInfo;
		// 判断PkHrorg是否为空
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getPkHrorg())) {
			bean.getPkHrorgName().setValue(uecOrgOrgsManager.getUecOrgOrgsNameByPkOrg(qryUecOutStaffInfo.getPkHrorg()));
		}
		groupDataTranslationDisplay();
	}

	/**
	 * 重置
	 * 
	 * @throws Exception
	 */
	public void onReset() throws Exception {
		clearVariable();
		bean.getOutStaffCode().setValue(null);
		bean.getOutStaffName().setValue(null);
		bean.getOutStaffIdNum().setValue(null);
		bean.getOutStaffPkHrorg().setValue(null);
		PubUtil.clearComponent(this);
		Events.postEvent(UecOutStaffConstants.ON_CLEAN_TAB_UEC_OUT_STAFF_INFO_QUERY, this, null);
	}

	/**
	 * 清除变量
	 */
	public void clearVariable() {
		uecOutStaffInfoVo = null;
		qryUecOutStaffInfo = null;
		uecOutStaffInfo = null;
	}

	/**
	 * 新增
	 * 
	 * @throws PortalException
	 * @throws SystemException
	 */
	public void onAdd() throws PortalException, SystemException {
		openUacStaffEditWin("add");
	}

	/**
	 * 编辑
	 * 
	 * @throws PortalException
	 * @throws SystemException
	 */
	public void onEdit() throws PortalException, SystemException {
		if (null != uecOutStaffInfo) {
			UecPsnjob uecPsnjob = UecPsnjob.newInstance();
			uecPsnjob.setStaffId(uecOutStaffInfo.getOutStaffId());
			uecPsnjob = uecPsnjobManager.findUecPsnjob(uecPsnjob);
			if (null != uecPsnjob) {
				if (null == uecPsnjob.getBegindate()) {
					ZkUtil.showInformation("任职信息时间为空", "温馨提示");
					return;
				}
				/*Date limitDate = DateUtil.patternStrToDate("2018-01-01");
				if (DateUtil.patternStrToDate(uecPsnjob.getBegindate()).getTime() >= limitDate.getTime()) {
					ZkUtil.showInformation("修改信息请申请流程", "温馨提示");
					return;
				}*/
			}
			openUacStaffEditWin("edit");
		}
	}

	/**
	 * 删除
	 * 
	 * @throws PortalException
	 * @throws SystemException
	 */
	public void onDel() throws PortalException, SystemException {
		if (null != uecOutStaffInfo) {
			try {
				Messagebox.show("您确定要删除吗？", "提示信息", Messagebox.OK | Messagebox.CANCEL, Messagebox.INFORMATION,
						new EventListener() {
							public void onEvent(Event event) throws Exception {
								Integer result = (Integer) event.getData();
								if (result == Messagebox.OK) {
									qryUecOutStaffInfo.setStatusCd("1100");
									qryUecOutStaffInfo.removeOnly();
									onReset();
								}
							}
						});
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 按钮设置
	 * 
	 * @param canAdd
	 * @param candel
	 */
	public void setUecStaffButtonValid(boolean canAdd, boolean canEdit, boolean canDel) {
		bean.getAddOutStaffButton().setDisabled(!canAdd);
		bean.getEditOutStaffButton().setDisabled(!canEdit);
		bean.getDelOutStaffButton().setDisabled(!canDel);
	}

	/**
	 * 关闭窗口事件
	 */
	public void onCloseWindown() {
		Events.postEvent("onCloseOutStaffMainWindown", this, onCloseFlag);
	}

	/**
	 * openUacStaffInfoWin
	 * 
	 * @param opType
	 */
	private void openUacStaffEditWin(String opType) {
		Map<String, Object> arg = new HashMap<String, Object>();
		arg.put("opType", opType);
		if (opType.equals("edit")) {
			arg.put("uecOutStaffInfo", uecOutStaffInfo);
		}
		Window win = (Window) Executions.createComponents(UecOutStaffConstants.UEC_OUT_STAFF_EDIT_ZUL, this, arg);
		try {
			win.doModal();
			win.addEventListener("onOK", new EventListener() {
				@Override
				public void onEvent(Event event) throws Exception {
					if (event.getData() != null) {
						uecOutStaffInfo = (UecOutStaffInfo) event.getData();
						PubUtil.fillBeanFromPo(uecOutStaffInfo, bean);
						qryUecOutStaffInfo=uecOutStaffInfo;
						stringTransToDate();
						groupDataTranslationDisplay();
					}
				}
			});
		} catch (SuspendNotAllowedException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 集团数据翻译展示,并向其他组件跑出事件
	 * 
	 * @throws ParseException
	 */
	public void groupDataTranslationDisplay() throws ParseException {
		if (null != uecOutStaffInfo) {
			// 职业资格管理
//			uecNationduty.setStaffId(uecOutStaffInfo.getId());
//			uecNationduty.setNmStaffType(BaseUnitConstants.NM_OUT_STAFF_TYPE);
//			uecNationduty = uecNationdutyManager.queryUecNationdutyById(uecNationduty);
//			if (null != uecNationduty) {
//				bean.getProf().setValue(customFilesManager.findCustomFilesByPkdefdoc(uecNationduty.getOccupation()));
//			}
			// 职业资格管理
			UecNationduty uecNationduty = uecNationdutyManager
					.getUecNationdutyByUecStaffInfo(uecOutStaffInfo);
			if (null != uecNationduty) {
				bean.getProf().setValue(
						customFilesManager
								.findCustomFilesByPkdefdoc(uecNationduty
										.getOccupation()));
			}
			// 专业技术职务
			if(StrUtil.isNullOrEmpty(uecOutStaffInfo.getOutStaffId())) {
					bean.getTitleTechpost()
							.setValue(null);
			}else {
				log.info(uecOutStaffInfo.getOutStaffId());
				//uecTitle.setStaffId(uecOutStaffInfo.getOutStaffId());
				//uecTitle.setNmStaffType(BaseUnitConstants.NM_OUT_STAFF_TYPE);
				uecTitle = uecTitleManager.findUecTitleByUecOutStaffInfo(uecOutStaffInfo);
				if (null != uecTitle) {
					bean.getTitleTechpost()
							.setValue(customFilesManager.findCustomFilesByPkdefdoc(uecTitle.getPkTechposttitle()));
				}
			}
			
			/*uecTitle.setStaffId(uecOutStaffInfo.getOutStaffId());
			uecTitle.setNmStaffType(BaseUnitConstants.NM_OUT_STAFF_TYPE);
			uecTitle = uecTitleManager.findUecTitle(uecTitle);
			if (null != uecTitle) {
				bean.getTitleTechpost()
						.setValue(customFilesManager.findCustomFilesByPkdefdoc(uecTitle.getPkTechposttitle()));
			}*/
			// 婚姻状况
			bean.getMarital().setValue(customFilesManager.findCustomFilesByPkdefdoc(uecOutStaffInfo.getMarital()));
			// 健康状况
			bean.getHealth().setValue(customFilesManager.findCustomFilesByPkdefdoc(uecOutStaffInfo.getHealth()));
			// 户口性质
			bean.getCharacterrpr()
					.setValue(customFilesManager.findCustomFilesByPkdefdoc(uecOutStaffInfo.getCharacterrpr()));
			// 民族
			bean.getNationality()
					.setValue(customFilesManager.findCustomFilesByPkdefdoc(uecOutStaffInfo.getNationality()));
			// 进入电信(邮电)系统来源
			bean.getGlbdef2().setValue(customFilesManager.findCustomFilesByPkdefdoc(uecOutStaffInfo.getGlbdef2()));
			
			
			/**
			 * 取政治面貌中的最新数据显示
			 */
			UecPartyLog uecPartyLog = uecPartyLogManager.getUecPartyLogByUecOutStaffInfo(uecOutStaffInfo);
			if(null != uecPartyLog){
				if(!StrUtil.isEmpty(uecPartyLog.getPartyName())){
					String partyName = uecPartyLog.getPartyName();
					bean.getPolity().setValue(customFilesManager.findCustomFilesByPkdefdoc(partyName));
					qryUecOutStaffInfo.setJoinPolityDate(uecPartyLog.getPartyDate());
				}
			}
			
			/**
			 * 根据教育经历中的数据显示
			 */
		/*	UecDocEdu uecDocEdu = uecDocEduManager
					.getUecDocEduByUecOutStaffInfo(uecOutStaffInfo);
			if (null != uecDocEdu) {
				// 学位
				if (!StrUtil.isEmpty(uecDocEdu.getPkDegree())) {
					String pkDegree = uecDocEdu.getPkDegree();
					bean.getDegree().setValue(
							customFilesManager
									.findCustomFilesByPkdefdoc(pkDegree));
				}
				// 最高学历
				if("Y".equals(uecDocEdu.getLasteducation())){
						bean.getHighestEducation().setValue("是");
				}else{
					bean.getHighestEducation().setValue("否");
				}
				
				// 全日制学历
				if (!StrUtil.isEmpty(uecDocEdu.getEducation())) {
					String education = uecDocEdu.getEducation();
					bean.getFulltimeEducation().setValue(
							customFilesManager
									.findCustomFilesByPkdefdoc(education));
				}
			}*/
			
			// 所属组织,根据任职信息里在职信息展示
			if(uecOutStaffInfo != null) {
				UecPsnjob	uecPsnjob=new UecPsnjob();
				uecPsnjob.setStaffId(uecOutStaffInfo.getOutStaffId());
				uecPsnjob.setNmStaffType("2");
				UecPsnjob findNewUecPsnjob = uecPsnjobManager.findNewUecPsnjob(uecPsnjob);
				String uecOrgOrgsNameByPkOrg = uecOrgOrgsManager.getUecOrgOrgsNameByPkOrg(findNewUecPsnjob.getPkOrg());
				if(!StrUtil.isNullOrEmpty(findNewUecPsnjob)) 
				    bean.getPkOrg().setValue(uecOrgOrgsNameByPkOrg);
		      	}else {
		      		bean.getPkOrg().setValue(null);
		      	}
			if(!StrUtil.isNullOrEmpty(uecOutStaffInfo.getPkHrOrgName())) {
              bean.getPkHrorgName().setValue(uecOutStaffInfo.getPkHrOrgName());
			}
			// 是否是门店营业员
			if (null != uecOutStaffInfo.getIsshopassist()) {
				String isshopassist = uecOutStaffInfo.getIsshopassist();
				if ("Y".equals(isshopassist)) {
					bean.getIsshopassist().setValue("是");
				} else if ("N".equals(isshopassist)) {
					bean.getIsshopassist().setValue("否");
				}
			}
			// 是否承包经营个人
			if (null != uecOutStaffInfo.getGlbdef14()) {
				String glbdef14 = uecOutStaffInfo.getGlbdef14();
				if ("Y".equals(glbdef14)) {
					bean.getGlbdef14().setValue("是");
				} else if ("N".equals(glbdef14)) {
					bean.getGlbdef14().setValue("否");
				}
			}
			if (uecOutStaffInfo.getIsZW() != null) {
				String isZW = uecOutStaffInfo.getIsZW();
				if ("Y".equals(isZW)) {
					bean.getIsZW().setValue("是");
				} else if ("N".equals(isZW)) {
					bean.getIsZW().setValue("否");
				} else {
					bean.getIsZW().setValue("");
				}
			}
			if (uecOutStaffInfo.getIsQD() != null) {
				String isQD = uecOutStaffInfo.getIsQD();
				if ("Y".equals(isQD)) {
					bean.getIsQD().setValue("是");
				} else if ("N".equals(isQD)) {
					bean.getIsQD().setValue("否");
				} else {
					bean.getIsQD().setValue("");
				}
			}
			/*if (uecOutStaffInfo.getIsSend() != null) {
				String isSend = uecOutStaffInfo.getIsSend();
				if ("1".equals(isSend)) {
					bean.getIsSend().setValue("是");
				} else if ("0".equals(isSend)) {
					bean.getIsSend().setValue("否");
				} else {
					bean.getIsQD().setValue("");
				}
			}
			if (uecOutStaffInfo.getDr() != null) {
				Long isDr = uecOutStaffInfo.getDr();
				if (1 == isDr) {
					bean.getDr().setValue("是");
				} else if (0 == isDr) {
					bean.getDr().setValue("否");
				} else {
					bean.getDr().setValue("");
				}
			}*/
			// 性别
			if (null != uecOutStaffInfo.getSex()) {
				String sex = uecOutStaffInfo.getSex();
				if ("1001A1100000000006A8".equals(sex)) {
					bean.getSex().setValue("男");
				} else if ("1001A1100000000006A9".equals(sex)) {
					bean.getSex().setValue("女");
				} else if ("1".equals(sex)) {
					bean.getSex().setValue("男");
				} else if ("2".equals(sex)) {
					bean.getSex().setValue("女");
				} else {
					bean.getSex().setValue("");
				}
			}
			// 证件类型
			if (null != uecOutStaffInfo.getIdtype()) {
				String idtype = uecOutStaffInfo.getIdtype();
				if ("0".equals(idtype)) {
					bean.getIdtype().setValue("身份证");
				} else if ("1".equals(idtype)) {
					bean.getIdtype().setValue("军官证");
				}else if ("2".equals(idtype)) {
					bean.getIdtype().setValue("护照");
				}else if ("3".equals(idtype)) {
					bean.getIdtype().setValue("香港身份证");
				}else if ("4".equals(idtype)) {
					bean.getIdtype().setValue("回乡证");
				}else if ("5".equals(idtype)) {
					bean.getIdtype().setValue("台湾身份证");
				}else if ("6".equals(idtype)) {
					bean.getIdtype().setValue("澳门身份证");
				}else if ("7".equals(idtype)) {
					bean.getIdtype().setValue("台胞证");
				}else if ("8".equals(idtype)) {
					bean.getIdtype().setValue("外国人永久居留证");
				} else {
					bean.getIdtype().setValue("");
				}
			}
			/**
			 * 人员属性--property 0:合同制用工 1：派遣制用工 2：外包自有 3：外包其他
			 */
			/*if (!StrUtil.isNullOrEmpty(uecOutStaffInfo.getProperty())) {
				String property = uecOutStaffInfo.getProperty();
				if ("2".equals(property)) {
					bean.getProperty().setValue("外包自有");
				} else if ("3".equals(property)) {
					bean.getProperty().setValue("外包其他");
				}
			}*/
		}

		// 重要！！
		Events.postEvent(UecOutStaffConstants.ON_UEC_OUT_STAFF_INFO_QUERY, this, uecOutStaffInfo);
	}

	/**
	 * 将String类型的日期转换成Date类型
	 */
	public void stringTransToDate() {
		/*// 出生日期
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getBirthDate())) {
			bean.getBirthDate().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getBirthDate()));
		}*/
		// 出生日期,从身份证号取
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getIdNum())) {
			String birthTemp=qryUecOutStaffInfo.getIdNum();
			String birth=birthTemp.substring(6,10)+"-"+birthTemp.substring(10,12)+"-"+birthTemp.substring(12,14);
			Date patternStrToDate = DateUtil.patternStrToDate(birth);
			bean.getBirthDate().setValue(patternStrToDate);
		}
		// 参加工作日期
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getJoinWorkDate())) {
			bean.getJoinWorkDate().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getJoinWorkDate()));
		}
		// 进入本单位时间
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getEnterUnitTime())) {
			bean.getEnterUnitTime().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getEnterUnitTime()));
		}
		// 进入电信系统日期
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getGlbdef3())) {
			bean.getGlbdef3().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getGlbdef3()));
		}
		// 入党(团)日期
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getJoinPolityDate())) {
			bean.getJoinPolityDate().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getJoinPolityDate()));
		}
		// 预计退休日期
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getGlbdef15())) {
			bean.getGlbdef15().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getGlbdef15()));
		}
		// 离退休日期
		/*if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getRetireDate())) {
			bean.getRetireDate().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getRetireDate()));
		}*/
		// 身故日期
		if (!StrUtil.isNullOrEmpty(qryUecOutStaffInfo.getDieDate())) {
			bean.getDieDate().setValue(DateUtil.patternStrToDate(qryUecOutStaffInfo.getDieDate()));
		}
	}

}
